package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.WxMaterMapper;
import com.ruoyi.system.domain.WxMater;
import com.ruoyi.system.service.IWxMaterService;
import com.ruoyi.common.core.text.Convert;

/**
 * materService业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-31
 */
@Service
public class WxMaterServiceImpl implements IWxMaterService 
{
    @Autowired
    private WxMaterMapper wxMaterMapper;

    /**
     * 查询mater
     * 
     * @param materId materID
     * @return mater
     */
    @Override
    public WxMater selectWxMaterById(Long materId)
    {
        return wxMaterMapper.selectWxMaterById(materId);
    }

    /**
     * 查询mater列表
     * 
     * @param wxMater mater
     * @return mater
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<WxMater> selectWxMaterList(WxMater wxMater)
    {
        return wxMaterMapper.selectWxMaterList(wxMater);
    }

    /**
     * 新增mater
     * 
     * @param wxMater mater
     * @return 结果
     */
    @Override
    public int insertWxMater(WxMater wxMater)
    {
        return wxMaterMapper.insertWxMater(wxMater);
    }

    /**
     * 修改mater
     * 
     * @param wxMater mater
     * @return 结果
     */
    @Override
    public int updateWxMater(WxMater wxMater)
    {
        return wxMaterMapper.updateWxMater(wxMater);
    }

    /**
     * 删除mater对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWxMaterByIds(String ids)
    {
        return wxMaterMapper.deleteWxMaterByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除mater信息
     * 
     * @param materId materID
     * @return 结果
     */
    @Override
    public int deleteWxMaterById(Long materId)
    {
        return wxMaterMapper.deleteWxMaterById(materId);
    }

    @Override
    public String checkPhoneUnique(WxMater wxMater) {
        WxMater mater = wxMaterMapper.checkPhoneUnique(wxMater.getMaterPhone());
        if (StringUtils.isNotNull(mater))
        {
            return UserConstants.USER_PHONE_NOT_UNIQUE;
        }
        return UserConstants.USER_PHONE_UNIQUE;
    }
}
